package com.qili.service.jc.impl;

import com.qili.base.mapper.BaseMapper;
import com.qili.base.service.impl.BaseServiceImpl;
import com.qili.entity.jc.JcProjectMilepost;
import com.qili.entity.supervisor.ProjectBigEvent;
import com.qili.entity.supervisor.SupervisorFile;
import com.qili.entity.supervisor.dto.ProjectBigEventDTO;
import com.qili.entity.jc.JcProjectStage;
import com.qili.mapper.supervisor.ProjectBigEventMapper;
import com.qili.service.jc.JcProjectBigEventService;
import com.qili.service.jc.JcProjectMilepostService;
import com.qili.service.jc.JcProjectStageService;
import com.qili.service.supervisor.ProjectBigEventService;
import com.qili.service.supervisor.SupervisorFileService;
import com.qili.service.zx.ZxProjectMilepostService;
import com.qili.service.zx.ZxProjectStageService;
import com.qili.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhaoyongke
 * @date 2021/1/11
 * @description 项目大事记
 */
@Service
public class JcProjectBigEventServiceImpl extends BaseServiceImpl<ProjectBigEvent,String> implements JcProjectBigEventService {


    @Autowired
    private  ProjectBigEventService projectBigEventService;
    @Autowired
    ProjectBigEventMapper projectBigEventMapper;
    @Autowired
    JcProjectStageService supervisorProjectStageService;
    @Autowired
    JcProjectMilepostService supervisorProjectMilepostService;
    @Autowired
    SupervisorFileService supervisorFileService;

    @Override
    public BaseMapper<ProjectBigEvent, String> getMappser() {
        return projectBigEventMapper;

    }
    /**
     * @Author:zhaoyongke
     * @Description:项目大事记  记录里程首次上传文档
     * @param projectId
     * @param spmid
     * @param stageId
     * @Date:15:37 2021/1/11
     */
    public void saveProejctBigEvent(String projectId,String spmid,String stageId) {
        JcProjectMilepost milepost=supervisorProjectMilepostService.selectByPrimaryKey(spmid);
        JcProjectStage stage=supervisorProjectStageService.selectByPrimaryKey(stageId);
        //项目大事记
        SupervisorFile file=new SupervisorFile();
        file.setProjectId(projectId);
        file.setSpmId(spmid);
        file.setStageId(stageId);
        int filecount=supervisorFileService.selectCount(file);
        if(filecount==0){
            /*项目大事记*/
            ProjectBigEvent  bigEvent=new ProjectBigEvent();
            bigEvent.setProLcNo(milepost.getMilepostNo());
            bigEvent.setProStageNo(stage.getStageNo());
            bigEvent.setProjectId(projectId);
            List<ProjectBigEvent> listevent=projectBigEventService.select(bigEvent);
            if(listevent.size()==0){
                bigEvent.setOperDate(DateUtil.getCurrentYearMonthDay());
                projectBigEventService.insertSelective(bigEvent);
            }

        }
    }
    /**
    * @Author:zhaoyongke
    * @Description:
    * @param dto
    * @Date:16:52 2021/1/11
    */
    public  List<ProjectBigEventDTO> selectProjectBigEvent(ProjectBigEventDTO  dto){

        List<ProjectBigEventDTO>  list=projectBigEventMapper.selectProjectBigEvent(dto);
        return list;
    }

}
